package com.ukao.cashregister.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.cashregister.R;
import com.ukao.cashregister.bean.ProductRelImgBean;
import com.ukao.cashregister.listener.OnItemChildClickListener;
import com.ukao.cashregister.utils.ImageUtils;

import java.util.List;

/**
 * Created by ukaodev on 2017/6/14.
 */

public class CameraPhotoAdapter extends CommonAdapter<ProductRelImgBean> {



    public CameraPhotoAdapter(Context context, List<ProductRelImgBean> datas ) {
        super(context, datas, R.layout.adapter_camera_photo);
    }

    private OnItemChildClickListener mOnItemChildClickListener;
    public  void  setOnItemChildClickListener(OnItemChildClickListener mOnItemChildClickListener){
        this.mOnItemChildClickListener=mOnItemChildClickListener;
    }




    @Override
    public void convert(final  ViewHolder holder, ProductRelImgBean item) {
        ImageView imagePhoto=holder.getView(R.id.image_photo);
        ImageView imageremove=holder.getView(R.id.image_remove);
        ImageUtils.loadImages(mContext,item.getCameraImg(),imagePhoto);
        imageremove.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnItemChildClickListener.onChildItemClick(v.getId(),getPosition(holder));
            }
        });
    }


}
